package day_2022_4_to_7.day48;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 幸运的袋子
 * @author haomin
 * @date 2022/05/10 09:07
 **/

public class Day14_2_LuckyBag {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] data = new int[num];
        for (int i = 0; i < data.length; i++) {
            data[i] = in.nextInt();
        }
        Arrays.sort(data);
        System.out.println(totalSum(data,0,0,1));
    }

    private static int totalSum(int[] a,int index,long sum,long multi){
        int count = 0;
        for(int i = index;i < a.length;i++){
            sum += a[i];
            multi *= a[i];

            if(sum > multi){
                count = count + 1 + totalSum(a, i+1, sum, multi);
            }
            else if (a[i] == 1) {
                count = count + totalSum(a, i+1, sum, multi);
            }
            else {
                break;
            }

            //sum和multi在下一循环中还会用到
            sum -= a[i];
            multi /= a[i];
            while (i < a.length-1 && a[i] == a[i+1]){
                i++;
            }
        }
        return count;
    }
}